angular.
  module('sendNewuser').
  component('sendNewuser', {
    templateUrl:
      'views/app/send-newuser/send-newuser.template.html',
    controller: function ($scope, $cookies, $http, $window, $location, $rootScope) {

      $scope.description = ''
      $scope.send = undefined

      $scope.ValidType = function(e){
        $scope.send = e
      }

      $http({
        method: 'post',
        url: '/admin/getDiscourse',
      }).success(function (datax) {
        if (datax != undefined) {
          console.log(datax)
          // for (var i  in datax.data){
          $scope.description = datax.data.description
          $scope.send = datax.data.send
          // }
        }
      })

      $scope.newSearchAccount = function () {
        var data = {}
        data.session = $cookies.get('sessionID')

        data.send = $scope.send
        data.description = $scope.description
        console.log(data)
        $http({
          method: 'post',
          url: '/admin/saveDiscourse',
          data: data
        }).success(function (datax) {
          if (datax.code == 200) {
            swal('保存成功', '', "success").then(function () {
            })
          }
          if (datax.code == 401) {
            $window.location = '/login'
          }
        })
      }
    }
  })



